<style type="text/css"> .inputfile { width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; position: absolute; z-index: -1; } #div-i-userDataContent p { display:flex; align-items:center; } #div-i-userDataContent p span { width: 54px; display:inline-block; } #div-i-userDataContent form p { margin-top: 32px; margin-bottom: 32px; } #div-i-userDataContent form p input { border-radius:6px; font-weight:bold; width:auto; flex-grow:1; } #span-i-submitUserData { font-size:20px; } #img-i-userAvatar { width:60px; height:60px; border-radius: 50%; margin-right:32px; } </style>
<div class="wapper" id="editMessage">
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center" style="height: 50px;line-height:50px;position: fixed;margin-top: 0px;left: 0px;z-index: 100;background-color:#059BF3;">
			<a class="glyphicon glyphicon-chevron-left fl " onclick="backPage()" style="cursor:pointer;color: white;font-size: 20px;position: absolute;top:50%;transform:translateY(-50%);left:10px;"></a>
			<strong style="font-size: 20px;color: white;">修改资料</strong>
		</div>
		<div id="div-i-userDataContent" class="col-xs-12 col-sm-4 col-sm-offset-4 text-center" >
			<div style="height:50px;"></div>
			<div  id="form-i-submitUserData" method="post" enctype="multipart/form-data">
				<input onchange='PreviewImage(this)' type="file" name="file" id="file-input-addAvatar" class="inputfile" />
				<p style="margin: 30px 0;"><span style="display:inline-block;min-width:48px;">昵称：</span><input class="form-control input-lg nicheng" name="nicheng" placeholder="请输入新的昵称"  value='' style="padding:10px 6px;" /></p>
				<span id="span-i-submitUserData" class="form-control input-lg btn btn-primary">提交修改</span>
			</div>
		</div>
		<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
			<div class="div-c-modalContent">
				<h3 class="fakemodal-title"></h3>
				<div class="fakemodal-content"></div>
				<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
			</div>
		</div>
	</div>

<script type="text/javascript">
	var qq = /^\d{5,12}$/;  /* qq号码格式验证 */	
		var userNiCheng;
		$.ajax({
			url:'/u/userInfos.do',   
			success:function(data){ 
				if(data == 50) { 
					save.push("sy");
					bindSetData("login"); 
					return;
	   			}else if(data==60){
	   				pagePreserve();
	   				return;
	   			}
				userNiCheng=data.data.nicheng;
				$(".nicheng").val(userNiCheng);
			},
		});
	function PreviewImage(imgFile) {
		var pattern = /(\.*.jpg$)|(\.*.png$)|(\.*.jpeg$)|(\.*.gif$)|(\.*.bmp$)|(\.*.JPG$)|(\.*.PNG$)|(\.*.JPEG$)|(\.*.GIF$)|(\.*.BMP$)/;
		if (!pattern.test(imgFile.value)) {
			alertme("系统仅支持jpg/jpeg/png/gif/bmp格式的照片！");
			document.getElementById("img-i-userAvatar").src = "/d/cp/"+userAvar+"";
			imgFile.focus();
		} else {
			var path;
			if (document.all) 
			{
				imgFile.select();
				path = document.selection.createRange().text;
				document.getElementById("imgPreview").innerHTML = "";
				document.getElementById("imgPreview").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\""
						+ path + "\")";/* 使用滤镜效果 */ 
			} else/* FF */ 
			{
				path = URL.createObjectURL(imgFile.files[0]);
				document.getElementById("img-i-userAvatar").src = path;
			}
		}
	}		
	var bindSubmitBtn = function() {
		$("#span-i-submitUserData").on("click", function(event) {
			$.ajax({
				type:'post',
				url:'/u/changeA1.do',
				data:{nicheng:$(".nicheng").val()},
				success:function(data){
					if(data == 50) { 
						save.push("sy");
						bindSetData("login"); 
						return;
		   			}else if(data==60){
		   				pagePreserve();
		   				return;
		   			}
					var newData=data.data;
					if(data.message==1){
						bindLayerLittle("提示：", "恭喜你，修改成功！");
						$(".nicheng").val(newData.nicheng);
					}else{
						bindLayerLittle("提示：", "很抱歉，修改失败！");
					}
				},
			}); 
		}); 
	};
	bindSubmitBtn();
	</script>

